﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using COM.PreAlarm.Model;
using COM.PreAlarm.BLL;
using HHH.Base;

public partial class Pages_Equip_Factory_Edit : ZMPageEdit<Equip_Factory,Equip_FactoryInfo>
{ 
	#region 重写方法

    private string key = "goodluke";

    protected override void OnBinding()
    {
        base.OnBinding();
        //设置编号
        if (IsNewModel)
        {
            //获取编号
            Equip_Factory Equip_Factory = new COM.PreAlarm.BLL.Equip_Factory();
            //Equip_Factory.a
            List<DBParameter> _listDBParameter = new List<DBParameter>();
            Equip_FactoryInfo_Factory_No.Value = StringHelper.FormatObjToString(Equip_Factory.ExecuteScalar("[dbo].[GetFactoryNO]", _listDBParameter, System.Data.CommandType.StoredProcedure));
            Equip_FactoryInfo_Factory_No.Disabled = true;

            //设置操作密码
            Random rnd = new Random();
            Equip_FactoryInfo_Op_Password.Value = rnd.Next(100000, 999999).ToString();
            Equip_FactoryInfo_Op_Password.Disabled = true;
        }
    }

    protected override void OnBinded()
    {
        base.OnBinded();
        //设置编号
        if (!IsNewModel)
        {
            //解密操作码
            Equip_FactoryInfo_Op_Password.Value = EncryptHelper.Decrypt(Model.Op_Password, key);
            Equip_FactoryInfo_Op_Password.Disabled = true;
        }
    }

    protected override void OnAchieve()
    {
        base.OnAchieve();
        //加密操作码
        Model.Op_Password = EncryptHelper.Encrypt(Equip_FactoryInfo_Op_Password.Value, key);
        
    }

    #endregion 	重写方法
}